<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddQrCodeDataToCarOwnersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('car_owners', function (Blueprint $table) {
            $table->text('qr_code_data')->nullable()->comment('二维码加密数据');
            
            if (!Schema::hasColumn('car_owners', 'qr_code_path')) {
                $table->string('qr_code_path', 255)->nullable()->comment('二维码图片路径');
            }
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('car_owners', function (Blueprint $table) {
            $table->dropColumn('qr_code_data');
        });
    }
}
